Skip to content

fix(core)!: Use ValueError for missing 'items' in array parameters #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025

Conversation

anubhav756
Copy link
Contributor

Overview

This PR improves the developer experience by providing more specific and actionable errors. When a tool parameter of type array was defined without its required items key, the SDK would raise a generic Exception. This made it difficult to distinguish this specific validation failure from other unexpected runtime exceptions.

This change corrects the behavior by raising a ValueError, which is the semantically appropriate exception for this scenario. The error message has also been slightly updated for consistency.

Before

  • Error Type: Exception
  • Error Message: "Unexpected value: type is 'list' but items is None"

After

  • Error Type: ValueError
  • Error Message: "Unexpected value: type is 'array' but items is None"

Testing

The unit test test_parameter_schema_array_no_items_error has been updated to reflect these changes.

## Overview
This PR improves the developer experience by providing more specific and actionable errors. When a tool parameter of type `array` was defined without its required `items` key, the SDK would raise a generic `Exception`. This made it difficult to distinguish this specific validation failure from other unexpected runtime exceptions.

This change corrects the behavior by raising a `ValueError`, which is the semantically appropriate exception for this scenario. The error message has also been slightly updated for consistency.

### Before
* Error Type: `Exception`
* Error Message: `"Unexpected value: type is 'list' but items is None"`

### After
* Error Type: `ValueError`
* Error Message: `"Unexpected value: type is 'array' but items is None"`

## Testing
The unit test `test_parameter_schema_array_no_items_error` has been updated to reflect these changes.
@anubhav756 anubhav756 self-assigned this Aug 1, 2025
@anubhav756 anubhav756 requested a review from a team as a code owner August 1, 2025 14:55
@anubhav756
Copy link
Contributor Author

/gcbrun

@anubhav756
Copy link
Contributor Author

/gcbrun

@anubhav756 anubhav756 merged commit b43409e into main Aug 4, 2025
20 checks passed
@anubhav756 anubhav756 deleted the anubhav-list-exception branch August 4, 2025 12:41
@release-please release-please bot mentioned this pull request Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants